﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;

namespace WPFReverseAndSortArrays
{
  // This class implements INotifyPropertyChanged
  // to support one-way and two-way bindings
  // (such that the UI element updates when the source
  // has been changed dynamically)
  public class Status : INotifyPropertyChanged
  {
      private string _status;
      // Declare the event
      public event PropertyChangedEventHandler PropertyChanged;

      public Status()
      {
          this.PropertyChanged += EventHander;
      }

      private void EventHander(Object o, PropertyChangedEventArgs args)
      {
          // MessageBox.Show(o.ToString());
      }

      public override string ToString()
      {
          return _status;
      }

      public Status(string value)
      {
          this._status = value;
          this.PropertyChanged += EventHander;
      }
      
      public string status
      {
          get { return _status; }
          set
          {
              _status = value;
              // Call OnPropertyChanged whenever the property is updated
              OnPropertyChanged("Status");
          }
      }

      // Create the OnPropertyChanged method to raise the event
      protected void OnPropertyChanged(string name)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
          if (handler != null)
          {
              handler(this, new PropertyChangedEventArgs(name));
          }
      }
    }
}
